import {
  q as i,
  p as R,
  ap as V,
  X as _,
  f as L,
  H as M,
  av as F,
  aw as T,
  k as n,
  m as t,
  az as O,
  as as u,
  aG as H,
  at as b
} from "./index-b50e6ef9.js";
import { k as y } from "./vip-d2446e08.js";
function G(W) {
  const c = i([]),
    s = i(!0);
  i({}), R();
  const v = i(1),
    m = i(10),
    p = i({}),
    x = V("reload"),
    g = _({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    A = _({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    B = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 40 },
      {
        label: "用户",
        prop: "user_name,user_phone",
        minWidth: 80,
        formatter: ({ user_name: e, user_phone: a }) =>
          n("div", null, [
            n("span", null, [t("姓名："), e]),
            n("br", null, null),
            n("span", null, [t("电话："), a])
          ])
      },
      {
        label: "授权人信息",
        prop: "shou_name,shou_phone,shou_card",
        minWidth: 120,
        formatter: ({ shou_name: e, shou_phone: a, shou_card: l }) =>
          n("div", null, [
            n("span", null, [t("姓名："), e]),
            n("br", null, null),
            n("span", null, [t("电话："), a]),
            n("br", null, null),
            n("span", null, [t("身份证："), l])
          ])
      },
      {
        label: "公司信息",
        prop: "faren,name,email,zhizao",
        minWidth: 120,
        formatter: ({ faren: e, name: a, email: l, zhizao: r }) =>
          n("div", null, [
            " ",
            n("span", null, [t("法人："), e]),
            n("br", null, null),
            n("span", null, [t("公司："), a]),
            n("br", null, null),
            n("span", null, [t("邮箱："), l]),
            n("br", null, null),
            n("span", null, [t("营业执照: "), r])
          ])
      },
      { label: "店铺名称", prop: "shop_name", minWidth: 80 },
      {
        label: "营业执照图片",
        prop: "image",
        minWidth: 100,
        cellRenderer: e =>
          n("div", null, [
            " ",
            n(
              "img",
              {
                src: e.row.image,
                style: "width: 150px; height: 100px;",
                alt: ""
              },
              null
            )
          ])
      },
      {
        label: "创建/修改",
        prop: "create_time,update_time",
        minWidth: 120,
        formatter: ({ create_time: e, update_time: a }) =>
          n("div", null, [
            " ",
            n("span", null, [t("创建："), e]),
            n("br", null, null),
            n("span", null, [t("修改："), a || "暂无修改"])
          ])
      },
      { label: "操作", fixed: "right", width: 150, slot: "operation" }
    ],
    w = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 40 },
      { label: "姓名", prop: "user_name", minWidth: 80 },
      { label: "电话", prop: "user_phone", minWidth: 80 },
      { label: "授权人姓名", prop: "shou_name", minWidth: 120 },
      { label: "授权人电话", prop: "shou_phone", minWidth: 120 },
      { label: "公司法人", prop: "faren", minWidth: 120 },
      { label: "公司", prop: "name", minWidth: 120 },
      { label: "邮箱", prop: "email", minWidth: 120 },
      { label: "店铺名称", prop: "shop_name", minWidth: 80 },
      { label: "营业执照图片", prop: "image", minWidth: 100 },
      { label: "创建", prop: "create_time", minWidth: 120 },
      { label: "操作", fixed: "right", width: 150, slot: "operation" }
    ],
    D = L(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function C(e) {
    O(e);
  }
  async function S(e) {
    const a = { role_id: e.role_id },
      l = JSON.stringify(a),
      d = { value: u.enc.Base64.stringify(u.enc.Utf8.parse(l)) },
      o = await H(d);
    o.code == 200
      ? (b("删除成功", { type: "success" }), x())
      : b(o.msg, { type: "error" });
  }
  function E() {}
  function I(e) {
    (m.value = e), f(void 0, e);
  }
  function z(e) {
    (v.value = e), f(e, void 0);
  }
  function k(e) {}
  function J(e) {
    (A.text = `正在加载第${e}页...`),
      (s.value = !0),
      F(600).then(() => {
        s.value = !1;
      });
  }
  async function U(e) {
    (s.value = !0), (p.value = e);
    const a = {
        page: 1,
        pagesize: m.value,
        user_phone: e.user_phone,
        shop_name: e.shop_name,
        shou_name: e.shou_name
      },
      l = JSON.stringify(a),
      d = { value: u.enc.Base64.stringify(u.enc.Utf8.parse(l)) },
      { data: o } = await y(d);
    (c.value = o.data),
      (g.total = o.total),
      setTimeout(() => {
        s.value = !1;
      }, 500);
  }
  async function f(e = v.value, a = m.value) {
    const l = {
        page: e,
        pagesize: a,
        user_phone: p.value.user_phone,
        shop_name: p.value.shop_name,
        shou_name: p.value.shou_name
      },
      r = JSON.stringify(l),
      o = { value: u.enc.Base64.stringify(u.enc.Utf8.parse(r)) },
      h = await y(o);
    h.code === 200
      ? ((c.value = h.data.data),
        (g.total = h.data.total),
        setTimeout(() => {
          s.value = !1;
        }, 500))
      : b(h.msg, { type: "error" });
  }
  const N = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    M(() => {
      F().then(() => {
        const { setWatermark: e } = T(W.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        f();
    }),
    {
      loading: s,
      columns: B,
      dataList: c,
      pagination: g,
      buttonClass: D,
      columnsExl: w,
      onSearch: U,
      resetForm: N,
      handleaddUser: E,
      handleUpdate: C,
      handleDelete: S,
      handleSizeChange: I,
      handleCurrentChange: z,
      handleSelectionChange: k,
      onCurrentChange: J
    }
  );
}
export { G as useRole };
